package com.me.mygdxgame;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Button;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.me.ultilities.Constants;

public class ButtonOfMenu {
	private Button button;
	private Texture texture1;
	private Texture texture2;

	

	public ButtonOfMenu(int x, int y, int width, int height, final int typeOfButton) {
	
		switch (typeOfButton) {	
		 case Constants.EXIT_BUTTON_TYPE: {
			texture1 = new Texture(Gdx.files.internal(Constants.EXIT_BUTTON));
			texture2 = new Texture(
					Gdx.files.internal(Constants.EXIT_BUTTON_PRESS));
			break;
		 }
		 case Constants.MISSION_BUTTON_TYPE: {
			texture1 = new Texture(Gdx.files.internal(Constants.MISSION_BUTTON));
			texture2 = new Texture(
					Gdx.files.internal(Constants.MISSION_BUTTON_PRESS));
			break;
		 }
		 case Constants.MORE_BUTTON_TYPE: {
			texture1 = new Texture(Gdx.files.internal(Constants.MORE_BUTTON));
			texture2 = new Texture(
					Gdx.files.internal(Constants.MORE_BUTTON_PRESS));
			break;
		 }
		 case Constants.PLAY_BUTTON_TYPE: {
			texture1 = new Texture(Gdx.files.internal(Constants.PLAY_BUTTON));
			texture2 = new Texture(
					Gdx.files.internal(Constants.PLAY_BUTTON_PRESS));
			break;
		 }
		default: {
			texture1 = new Texture(Gdx.files.internal(Constants.SHOP_BUTTON));
			texture2 = new Texture(
					Gdx.files.internal(Constants.SHOP_BUTTON_PRESS));
			break;
		}
		}

		TextureRegion region1 = new TextureRegion(texture1);
		TextureRegion region2 = new TextureRegion(texture2);
		button = new Button(new TextureRegionDrawable(region1),
				new TextureRegionDrawable(region2));
		// btnExit.setBounds(710, 400, 70, 70);
		button.setBounds(x, y, width, height);
		button.addListener(new ChangeListener() {

			@Override
			public void changed(ChangeEvent event, Actor actor) {
				// TODO Auto-generated method stub
				switch (typeOfButton) {
				 case Constants.EXIT_BUTTON_TYPE: {
					Gdx.app.exit();
					break;
				 }
				 case Constants.MISSION_BUTTON_TYPE: {
					System.out.println("mission button pressed");
					break;
				 }
				 case Constants.MORE_BUTTON_TYPE: {
					 System.out.println("more button pressed");
					break;
				 }
				 case Constants.PLAY_BUTTON_TYPE: {
					 System.out.println("play button pressed");
					break;
				 }
				default: {
					System.out.println("shop button pressed");
					break;
				}
				}
	

			}
		});

	}

	public void addToStage(Stage stage) {
		stage.addActor(button);
	}
}
